package com.pubinfo.passbook.common.model.constant;

import com.pubinfo.passbook.common.exception.ServiceException;
import com.pubinfo.passbook.common.model.vo.base.BusinessErrorCode;

public enum RoleEnum {
  
  ADMIN("管理员", "passbook_admin"),
  USER("普通用户", "passbook_user"),
  AUDITOR("医药费审核员", "passbook_bill_auditor"),
  Department("部门报销员", "passbook_reimbursement_clerk"),
  CONTRACT_ADMIN("拆迁赔补费系统管理员", "contract_admin"),
  CONTRACT_RESPONSIBLE("分公司管理员-赔补", "contract_responsible"),
  contract_unit_leader("单位负责人", "contract_unit_leader"),
  CONTRACT_CLAIMANT("合同认领人", "contract_claimant"),
  CONTRACT_FINANCE("财务人员", "contract_finance");
  
  public String roleName;
  public String roleCode;
  
  RoleEnum(String roleName, String roleCode) {
    this.roleCode = roleCode;
    this.roleName = roleName;
  }
  
  public String getRoleName() {
    return this.roleName;
  }
  
  public String getRoleCode() {
    return this.roleCode;
  }
  
  public static String getRoleCode(String key) {
    for (RoleEnum e : RoleEnum.values()) {
      if (e.getRoleName().equals(key)) {
        return e.getRoleCode();
      }
    }
    return null;
  }
  
  public static RoleEnum getEnum(String status) {
    for (RoleEnum e : RoleEnum.values()) {
      if (status.equals(e.getRoleCode())) {
        return e;
      }
    }
    throw new ServiceException(BusinessErrorCode.STATUS_NOT_EXIST);
  }
}
